package com.xy.p2p.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.p2p.dao.TmembercreditDao;
import com.xy.p2p.model.Tmembercredit;
import com.xy.p2p.service.TmembercreditService;

@Service
@Transactional
public class TmembercreditServiceImpl extends BaseServiceImpl<Tmembercredit> implements
		TmembercreditService {
	private TmembercreditDao tmembercreditDao;

	public TmembercreditServiceImpl(TmembercreditDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tmembercreditDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tmembercreditDao.checkExist("Tmembercredit", paraName, paraValue);
	}

	@Override
	public List<Tmembercredit> getTmembercredit(Map<String, Object> map) {
		return tmembercreditDao.getTmembercredit(map);
	}
	@Override
	public Pagination getTmembercreditByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tmembercreditDao.getTmembercreditByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tmembercredit save(Tmembercredit tmembercredit) {
//		tmembercredit.setModtime(new Date());
		if(tmembercredit.getMcid()==null){
			//新增
        	return super.save(tmembercredit);
		}else{
			//更新
			Tmembercredit tmembercredit1=tmembercreditDao.get(tmembercredit.getMcid());
			try {
				BeanUtil.copyNotNullProperties(tmembercredit1, tmembercredit);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tmembercredit1);
		}
	}
}